                <!-- table -->
				<div class="box">
					<!-- box / title -->
					<div class="title">
						<h5>
                            <?=$title;?>
                            <?php if($month!='-')
                                //echo $coa.' Periode ' .indonesian_date($date_start).' s/d '.indonesian_date($date_end);
                            ?>
                        </h5>
						<div class="search">
                        <?php if($month!='-'): ?>
                            <?=form_open('cashflow/cash/getGeneralLedgerExport')?>
								<div class="input">
                                    <label class="search"><?=lang('export')?></label>
									<?=form_dropdown('export',config('export'))?>
								</div>
								<div class="button">
									<?=form_submit('submit',lang('export'))?>
								</div>
							<?=form_close()?>
                        
                        <?php else:?>
                            <?=form_open('cashflow/cash/getGeneralLedger')?>
								<div class="input">
                                    <?=form_dropdown('month',config('month'),date('m'))?>
                                    <?=form_dropdown('year',config('year'),date('Y'))?>
								</div>

                                <div class="input">
									<?=form_dropdown('budget',$budgets,'','style="width:140px"')?>
								</div>
								<div class="button">
									<input type="submit" name="submit" value="Search" />
								</div>
							<?=form_close()?>
                         <?php endif;?>   
						</div>
					</div>
					<!-- end box / title -->
					<div class="table">
                    
                        <?php if($this->session->flashdata('success')):?>
						<div id="message-success" class="message message-success">
							<div class="image">
								<img src="resources/images/icons/success.png" alt="Success" height="32" />
							</div>
							<div class="text">
								<h6>Send Email</h6>
								<span>Send Email Success to Recipient , to Edit email set to Settings Menu !</span>
							</div>
							<div class="dismiss">
									<a href="#message-success"></a>
							</div>
						</div>
						<?php elseif($this->session->flashdata('error')):?>
						<div id="message-error" class="message message-error">
								<div class="image">
									<img src="resources/images/icons/error.png" alt="Error" height="32" />
								</div>
								<div class="text">
									<h6>Send Email</h6>
									<span>Send Email Error to Recipient , to Edit email set to Settings Menu !</span>
								</div>
								<div class="dismiss">
									<a href="#message-error"></a>
								</div>
						</div>
						<?php endif;?>
                        
                        
                        <?php if($month!='-'):?>
                        <div class="action">
                            <?=anchor('cashflow/cash/getGeneralLedgerReset','Kembali Ke Awal');?>
			         	</div>
                        <?php endif;?>
                        
						<table>
							<thead>
								<tr>
									<th style="vertical-align: middle;"  rowspan="2"><?=lang('date')?></th>
                                    <th style="vertical-align: middle;"  rowspan="2"><?=lang('description')?></th>
                                    <th style="vertical-align: middle;"  rowspan="2"><?=lang('dept')?></th>
                                    <th style="vertical-align: middle;"  rowspan="2"><?=lang('debet')?></th>
                                    <th style="vertical-align: middle;"  rowspan="2"><?=lang('credit')?></th>
                                    <th style="vertical-align: middle;"  colspan="2"><?=lang('saldo')?></th>
								</tr>
                                <tr>
                                    <th><?=lang('debet')?></th>
                                    <th><?=lang('credit')?></th>
								</tr>
							</thead>
							<tbody>
                                <?php 
                                
                                foreach($accounts as $row):?>
                                <?php $ledger = $this->cashs->getCashFlow($year,$month,$row['MataAnggaran']);?>
                                <?php if(COUNT($ledger)):?>
                                    <tr>
                                        <th></th>
                                        <th><p><?=$row['Ikhtisar']?></p></td>
                                        <th><?=$row['MataAnggaran']?></td>
                                        <th></th>
                                        <th></th>
                                        <th></th>
                                        <th></th>
                                    </tr>
                                    <?php 
                                        $saldo_credit=0;
                                        $saldo_debet=0;
                                        $credit=0;
                                        $debet=0;
                                        $i=0;
                                        foreach($ledger as $val):?>
                                    <?php
                                        /** Credit & Debet **/
                                        if($val['cash_id_in']!=0 || $val['cash_id_transfer']!=0):/** masuk kredit **/
                                			$credit= $val['Credit'];
                                			$debet = 0;
                                		elseif($val['cash_id_out']!=0 || $val['petty_cash_id']!=0): /** masuk debet **/
                                			$debet = $val['Credit'];
                                			$credit= 0;
                                		endif;
                                        
                                        /** Saldo **/
                                        if($i==0):
                                			if($credit!=0)
                                				 $saldo_credit= $credit;				 
                                			else $saldo_debet = $debet;
                                			 
                                		else:
                                			if($credit!=0):
                                				if($saldo_credit!=0):
                                					$saldo_credit=$saldo_credit+$credit;				 
                                				else:
                                					$saldo_debet=$saldo_debet-$credit;				 
                                					if($saldo_debet < 0):
                                						$saldo_credit=abs($saldo_debet);
                                						$saldo_debet=0;
                                					endif;
                                				endif; 
                                			else:
                                				if($saldo_debet!=0):
                                					$saldo_debet=$saldo_debet+$debet;
                                				else:
                                					$saldo_credit=$saldo_credit-$debet;
                                					if($saldo_credit < 0):
                                						$saldo_debet=abs($saldo_credit);
                                						$saldo_credit=0;
                                					endif;
                                				endif;
                                 			endif; 
                                            
                                        endif; 
                                        
                                        /** Credit & Debit **/
                                        if($credit!=0):
                                			$is_credit= number_format($credit,2,".",",");
                                			$is_debet = "";
                                		endif;
                                		if($debet!=0):
                                			$is_debet = number_format($debet,2,".",",");
                                			$is_credit= "";
                                		endif;
                                        
                                        /** saldo Credit & Debit **/
                                        if($saldo_credit!=0):
                                			$is_saldo_credit=number_format($saldo_credit,2,".",",");
                                			$is_saldo_debet="";
                                		endif;
                                        
                                		if($saldo_debet!=0):
                                			$is_saldo_debet=number_format($saldo_debet,2,".",",");
                                			$is_saldo_credit="";
                                		endif;
                                    ?>
                                        <tr>
                                            <td><?=substr($val['Tanggal'],8,2)?></td>
                                            <td><p><?=$val['Keterangan']?></p></td>
                                            <td><?=$val['DeptId']?></td>
                                            <td><?=$is_debet?></td>
                                            <td><?=$is_credit?></td>
                                            <td><?=$is_saldo_debet?></td>
                                            <td><?=$is_saldo_credit?></td>
                                        </tr>
                                    <?php 
                                        $i++;
                                    endforeach;?>
                                    
                                <?php
                                    endif; 
                                endforeach;?>
							</tbody>
						</table>
                        
                        <?php if($month!='-'):?>
                        <div class="action">
                            <?=anchor('cashflow/cash/getGeneralLedgerReset','Kembali Ke Awal');?>
			         	</div>
                        <?php endif;?>
                        
					</div>
				</div>
				<!-- end table -->